Skip to content

Conversation

@ElFantasma
Copy link
Contributor

Motivation
We need to support DiscV5

Description

This is a WIP that adds a discv5::server and discv5::peer_table to support the protocol.
It is an unfinished set of features, but I pretend to merge this big PR to be able to work in sub-features separately. All this functionality is still behind an experimental-discv5 feature flag, so none of this code is run if the feature is not enabled. Discv4 still is the only supported protocol.

Currently this performs:

  • Outgoing handshake (including secret sharing and encryption)
  • FindNode requests
  • handles Nodes responses
  • Populates the PeerTable with these responses
    With this functionality it is enough to start testing and even finding some useful peers, but this does not complete the spec:

I will start issuing in a set of tickets the missing functionality. But mostly:

  • It does not handle incoming FindNode or handshake requests
  • It does not filter peers using the ENR information
  • It does not revalidate or clean up discarded peers
  • Several other validations need to be done
  • It lacks some encoding/decoding tests

ElFantasma and others added 30 commits December 9, 2025 10:31
**Motivation**

<!-- Why does this pull request exist? What are its goals? -->

**Description**

<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves #111, Resolves #222 -->

**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5574 and #5575.

Co-authored-by: Esteban Dimitroff Hodi <[email protected]>
**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5580 and #5581
**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5578 and #5579
**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5576 and closes #5577
**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #issue_number
**Motivation**
I saw current new_nonce impl allocated a vector when it can just return
a fixed size array.

**Description**

Removes the needless vec

**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.
**Motivation**

In order to start merging discv5 code into main, to avoid having a huge
PR at the end of the development, we should create a feature flag
disabled by default.

Closes #5639
**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5586
Closes #5587
**Motivation**

<!-- Why does this pull request exist? What are its goals? -->

**Description**

<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves #111, Resolves #222 -->

**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.
**Motivation**

<!-- Why does this pull request exist? What are its goals? -->

**Description**

<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves #111, Resolves #222 -->

**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5570
Closes #5571
**Checklist**

- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.

Closes #5566
Closes #5567
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

Lines of code report

Total lines added: 1867
Total lines removed: 82
Total lines changed: 1949

Detailed view
+---------------------------------------------------+-------+-------+
| File                                              | Lines | Diff  |
+---------------------------------------------------+-------+-------+
| ethrex/cmd/ethrex/cli.rs                          | 818   | -2    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/common/rlp/structs.rs               | 167   | +3    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/discv5/codec.rs      | 33    | -39   |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/discv5/messages.rs   | 1187  | +196  |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/discv5/mod.rs        | 5     | +2    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/discv5/peer_table.rs | 1139  | +1139 |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/discv5/server.rs     | 511   | +511  |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/discv5/session.rs    | 124   | -33   |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/network.rs           | 362   | -4    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/p2p.rs               | 23    | +8    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/rlpx/initiator.rs    | 101   | -4    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/types.rs             | 542   | +3    |
+---------------------------------------------------+-------+-------+
| ethrex/crates/networking/p2p/utils.rs             | 194   | +5    |
+---------------------------------------------------+-------+-------+

@ElFantasma ElFantasma changed the title Discv5 server - WIP feat(l1): Discv5 server - WIP Jan 8, 2026
@github-actions github-actions bot added the L1 Ethereum client label Jan 8, 2026
@ElFantasma ElFantasma changed the title feat(l1): Discv5 server - WIP feat(l1): discv5 server - WIP Jan 8, 2026
@ElFantasma ElFantasma changed the title feat(l1): discv5 server - WIP feat(l1): discv5 server Jan 12, 2026
Copy link
Contributor

@iovoid iovoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had decoding errors, apparently related to nodes sending the signature in an uncompressed format. Maybe this should be fixed, or the error should be downgraded to trace/debug and the limitation documented.

@ElFantasma
Copy link
Contributor Author

I've had decoding errors, apparently related to nodes sending the signature in an uncompressed format. Maybe this should be fixed, or the error should be downgraded to trace/debug and the limitation documented.

Fixed 👍

@github-project-automation github-project-automation bot moved this to In Review in ethrex_l1 Jan 16, 2026
@ElFantasma ElFantasma added this pull request to the merge queue Jan 16, 2026
Merged via the queue into main with commit ff00c88 Jan 16, 2026
52 checks passed
@ElFantasma ElFantasma deleted the discv5-server branch January 16, 2026 19:09
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants